package com.syq.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author Sun Yueqi
 * @version 1.00
 * @time 2022/5/26 20:29
 */
@Configuration
public class BeanConfig {

    @Bean
    public ThreadPoolExecutor threadPoolExecutor(){
        return new ThreadPoolExecutor(
                5,
                10,
                120,
                 TimeUnit.SECONDS,
                 new LinkedBlockingQueue<>(20),
                 Executors.defaultThreadFactory(),
                 new ThreadPoolExecutor.AbortPolicy());
    }
}
